package org.scirp.ijmis.dao.common.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.scirp.ijmis.dao.base.impl.BaseDAOImpl;
import org.scirp.ijmis.dao.common.ISurveyChoiceDAO;
import org.scirp.ijmis.po.common.Survey;
import org.scirp.ijmis.po.common.SurveyChoice;

public class SurveyChoiceDAOImpl extends BaseDAOImpl<SurveyChoice> implements ISurveyChoiceDAO {

	private static final String className = SurveyChoiceDAOImpl.class.toString();

	public List<SurveyChoice> selectAll() {
		String hql = "from SurveyChoice order by pid asc";
		return super.ExecuteQuery(hql, className + "-->selectAll");
	}

	public SurveyChoice selectById(Object id) {
		return (SurveyChoice) super.selectById(id, className + "-->selectById");
	}
	
	@Override
	public List<SurveyChoice> selectBySurveyId(Long surveyId) {
		String hql="from SurveyChoice where survey.pid=:surveyId";
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("surveyId", surveyId);
		return super.ExecuteQuery(hql, map, className+"-->selectBySurveyId(Long surveyId)");
	}
	public boolean updateSurveyChoice(SurveyChoice surveyChoice) {
		return super.updateObject(surveyChoice, className + "-->updateSurveyChoice(SurveyChoice surveyChoice)");
	}
	public boolean deleteSurveyChoiceById(Long surveyChoiceId) {
		String hql = "delete SurveyChoice where pid=:surveyChoiceId";
		Map<String, Long> parameters = new HashMap<String, Long>(0);
		parameters.put("surveyChoiceId", surveyChoiceId);
		return super.ExecuteNonQuery(hql, parameters, className + "-->deleteSurveyChoiceById(Long surveyChoiceId)");
	}
	public boolean deleteSurveyChoiceBySurveyId(Long surveyId) {
		String hql = "delete SurveyChoice where surveyId=:surveyId";
		Map<String, Long> parameters = new HashMap<String, Long>(0);
		parameters.put("surveyId", surveyId);
		return super.ExecuteNonQuery(hql, parameters, className + "-->deleteSurveyChoiceBySurveyId(Long surveyId)");
	}
	
	public SurveyChoice deleteSurveyChoice(SurveyChoice surveyChoice) {
		return super.deleteObject(surveyChoice, className + "-->deleteSurveyChoice(SurveyChoice surveyChoice)");
	}
	
	
}
